<?php
header('Content-Type:text/html;charset=UTF-8');

session_start();

if(isset($_SESSION['user'])){

}else {
	die('<h3>登录信息不完整</h3><a href="/index.php">返回重新登录</a>');
};

@$entryId=$_REQUEST['entryId'];
@$ordersId=$_REQUEST['ordersId'];

require 'lib/db.php';


if(!empty($entryId)&&!empty($ordersId)){
	dbInsert("insert into cart(entryId,ordersId) values(:entryId,:ordersId)",array('entryId'=>$entryId,'ordersId'=>$ordersId));
}

// @$entry = dbSelect("select id,name,price,imgUrl,purchase,stock from entry where id=:id",array('id'=>$id));
@$cart = dbSelectAll('select *from cart join entry on cart.entryId=entry.id');


?>
<!DOCTYPE html>
<html>
   <head>
      <title>SuperMarket</title>
	  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="UTF-8" >
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <script src="bootstrap/js/jquery-1.11.1.min.js"></script>
      <script src="bootstrap/js/bootstrap.min.js"></script>
      <!--[if lt IE 9]>
         <script src="js/html5shiv.js"></script>
         <script src="js/respond.min.js"></script>
      <![endif]-->
   </head>
<script>

</script>
   <style>
   <?php if($entryId==''||$ordersId==''){?>
   	#show{display:none}
   	#main{display:block}
   <?php }else{?>
   	#show{display:block}
   	#main{display:none}
   <?php }?>
  #main{background:#dddddd;}
   #A{color:red}
   #a{color:#62b0ff;}
   #h4{color:gray}
   .a{color:red;text-align:center}
   #td{font-size:25px;color:black;}
   #td1{font-size:15px;color:gray;}
   #deleteButton{color:red;}
   .titles{margin:10px}
   #div{;height:20px;}
   #div1{height:160px;margin:px;}
   #hr{height:3px;background:black;margin:10px}
   .br{height:160px;text-align:center;background:#fbf3bb;}
   .thumbnail1{width: 140px;height:115px;background:#fbf3bb;margin:10px}
   .img{height: 25px;width: 260px;float: left;text-align:center}
   #DIV{height: 20px;margin:40px}
   .shop{margin:100px}
   #h{color:black;font-size:20px}
   #page{color:blue;font-size:19px}
   .title{height:50px;text-align:center;font-size:18px}
   #input{width:80px}
   #settleButton{color:red}
   #show{background:#dddddd;}
   #price{margin:40px}
  </style>
   <body>
<div class="navbar navbar-default">
  <div class="container">
  	<a class="navbar-brand glyphicon glyphicon-shopping-cart" href="First.php" id="a">宜家超市</a>
  		<ul class="nav navbar-nav">
  			<li class="dropdown">
  				<a href="#" class="dropdown-toggle" data-toggle="dropdown" >档案管理 <span class="caret"></span></a>
  					<ul class="dropdown-menu">
  					<li><a href="manager.php">职工列表</a></li>
  					<li><a href="member.php">管理员</a></li>
  					</ul>
  			</li>
  		  </ul>
		<ul class="nav navbar-nav">
			<li class="dropdown">
			 <a href="#" class="dropdown-toggle" data-toggle="dropdown" >商品管理 <span class="caret"></span></a>
				<ul class="dropdown-menu">
					<li><a href="Addmerchandise.php">商品进货</a></li>
					<li><a href="merchandiseDish.php">商品列表</a></li>
				</ul>
			</li>
		  </ul>
		<ul class="nav navbar-nav">
			<li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown" >营业管理 <span class="caret"></span></a>
					<ul class="dropdown-menu">
						<li><a href="#">支出明细</a></li>
						<li><a href="income.php">收入明细</a></li>
					</ul>
				</li>
			</ul>
			<ul class="nav navbar-nav">
			<li class="dropdown">
			 <a href="#" class="dropdown-toggle" data-toggle="dropdown" >我的购物车 <span class="caret"></span></a>
				<ul class="dropdown-menu">
					<li><a href="Adddesk.php">我的商品</a></li>
					<li><a href="#">消费记录</a></li>
					<li><a href="#">我的收藏</a></li>
				</ul>
			</li>
		  </ul>
			<ul class="nav navbar-nav">
			<li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown" >权限管理 <span class="caret"></span></a>
					<ul class="dropdown-menu">
						<li><a href="#">我的权限</a></li>
						<li><a href="#">关于超市</a></li>
					</ul>
				</li>
			</ul>
	 	 <ul class="nav navbar-nav">
	  		<li class="dropdown">
	  			<a href="#" class="dropdown-toggle" data-toggle="dropdown" >登录管理 <span class="caret"></span></a>
	  				<ul class="dropdown-menu">
				  		<li><a href="#" data-toggle="modal" data-target="#2">退出登录</a></li>
	  				</ul>
		</li>
	</ul>
 </div>
</div>
	<div id="2" class="modal">
					<div class="modal-dialog">				
					<div class="modal-content">
							<div class="modal-header">
								<span class="close" data-dismiss="modal">&times;</span>
								  <div class="modal-title">
									<h4>确定退出登录</h4>
								  </div>
									</div>
							<div class="modal-body">
								你确定要退出登录吗？
							</div>
							<div class="modal-footer">
							 <a type="submit" class="btn btn-default" href="logout.php">确定</a>
							 <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
							</div>
						</div>
					</div>
				</div>

<div class="container">
		<div class="col-xs-12 titles" id="show">
			<div id="div">
				<a href="First.php" id="A">宜家超市店铺：宜家超市</a>
			</div>
			<div id="hr"></div>
			<div class="title">
				<div class="col-xs-3">
				商品信息　　　　　　
				</div>
				<div class="col-xs-2">
				单价（元）
				</div>
				<div class="col-xs-2">
				数量
				</div>
				<div class="col-xs-2">
				金额
				</div>
				<div class="col-xs-3">
				操作
				</div>
			</div>
					<?php 
					if (!empty($entryId)){
						@$list = dbSelectAll("select *from cart join entry on cart.entryId=entry.id where ordersId=:ordersId",array('ordersId'=>$ordersId));
						foreach ($list as $item){
					?>
					<div id="div1">
						<div class="col-xs-3 br">
							<div class="thumbnail1">
								<img src="img/<?php echo $item['imgUrl']; ?>" style="height:125px" />
							</div>
							<div class="img">
								<img src="//assets.alicdn.com/sys/common/icon/trade/xcard.png" title="支持信用卡支付">
								<img src="//img.alicdn.com/tps/i4/T1BCidFrNlXXaSQP_X-16-16.png" title="消费者保障服务，卖家如实描述">
							</div>
						</div>
						<div class="col-xs-2 br">
							<div id="price">
								<?php echo $item['price']; ?>
							</div>
						</div>
						<div class="col-xs-2 br">
							<div id="price">
								<input type="number" min="1" id="input" value="1"/>
							</div>
						</div>
						<div class="col-xs-2 br">
							<div id="price">
								<?php echo $item['purchase']; ?>
							</div>
						</div>
						<div class="col-xs-3 br">
							<div id="DIV">
								<a href="deleteDesk.php?id=<?php echo $item['id']; ?>" id="deleteButton">删除</a>
								<a href="#" data-toggle="modal" data-target="#3">结账</a>
								<a href="First.php">返回</a>
							</div>
						</div>
					</div>
					<?php } }?>
				
		</div>
		
			<div class="col-xs-12 titles" id="main">
			<div id="div">
				<a href="First.php" id="A">宜家超市店铺：宜家超市</a>
			</div>
			<div id="hr"></div>
			<div class="title">
				<div class="col-xs-3">
				商品信息　　　　　　
				</div>
				<div class="col-xs-2">
				单价（元）
				</div>
				<div class="col-xs-2">
				数量
				</div>
				<div class="col-xs-2">
				金额
				</div>
				<div class="col-xs-3">
				操作
				</div>
			</div>
					<?php 
						foreach ($cart as $carts){
					?>
					<div id="div1">
						<div class="col-xs-3 br">
							<div class="thumbnail1">
								<img src="img/<?php echo $carts['imgUrl']; ?>" style="height:125px" />
							</div>
							<div class="img">
								<img src="//assets.alicdn.com/sys/common/icon/trade/xcard.png" title="支持信用卡支付">
								<img src="//img.alicdn.com/tps/i4/T1BCidFrNlXXaSQP_X-16-16.png" title="消费者保障服务，卖家如实描述">
							</div>
						</div>
						<div class="col-xs-2 br">
							<div id="price">
								<?php echo $carts['price']; ?>
							</div>
						</div>
						<div class="col-xs-2 br">
							<div id="price">
								<input type="number" min="1" id="input" value="1"/>
							</div>
						</div>
						<div class="col-xs-2 br">
							<div id="price">
								<?php echo $carts['purchase']; ?>
							</div>
						</div>
						<div class="col-xs-3 br">
							<div id="DIV">
								<a href="deleteDesk.php?id=<?php echo $carts['id']; ?>" id="deleteButton">删除</a>
								<a href="#" data-toggle="modal" data-target="#3">结账</a>
								<a href="First.php">返回</a>
							</div>
						</div>
					</div>
					<?php }?>
			</div>
			
			<div class="modal" id="3">
			<div class="col-sm-4 col-md-4 col-xs-offset-4">
		        <div class="panel panel-primary">
			            <div class="panel-heading">
			               <h5>结账</h5>
			            </div>
		                    <div class="panel-body">
		                    <form id="stockFrom" class="form-horizontal" enctype="multipart/form-data" action="Addstock.php" method="post">
		                    <div class="form-group">
		                        <label class="control-label col-sm-3 hidden-xs">商品：</label>
		                        <div class="col-sm-4">
		                            <input name="name" value="<?php echo $carts['name']; ?>" class="form-control" disabled="disabled"/>
		                        </div>
		                    </div>
		                    	
		                    <div class="form-group">
		                        <label class="control-label col-sm-3 hidden-xs">价格：</label>
		                        <div class="col-sm-4">
		                            <input  name="price" value="<?php echo $carts['price']; ?>" class="form-control"  disabled="disabled"/>
		                        </div>
		                    </div>
		                    <div class="row">
		                        <div class="col-xs-3 col-xs-offset-3">
		                          	<a href="settleDesk.php" class="btn btn-warning" id="but">结账</a>
		                        </div>
		                        <div class="col-xs-3 col-xs-3">
		                          	<a type="button" class="btn btn-default" data-dismiss="modal">取消</a>
		                        </div>
		                    </div>
		                    </form>
		            </div>
		        </div>
			</div>
		</div>
	

</div>
</body>

</html>









